package com.cjm.one.custom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cjm.one.custom.service.CustomerLoginLogService;
import com.cjm.one.custom.mapper.CustomerLoginLogMapper;
import com.cjm.one.model.custom.entity.CustomerLoginLog;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
* @author 29289
* @description 针对表【customer_login_log(客户登录记录)】的数据库操作Service实现
* @createDate 2024-09-05 16:25:23
*/
@Service
public class CustomerLoginLogServiceImpl extends ServiceImpl<CustomerLoginLogMapper, CustomerLoginLog>
    implements CustomerLoginLogService {
    @Resource
    private CustomerLoginLogMapper customerLoginLogMapper;
    @Override
    public Boolean add(CustomerLoginLog customerLoginLog) {

        return customerLoginLogMapper.insert(customerLoginLog) >0;
    }

    @Override
    public Page<CustomerLoginLog> pageList(Integer current, Integer size, String customerId, String startTime, String endTime) {
        Page<CustomerLoginLog> page = new Page<>(current, size);
        LambdaQueryWrapper<CustomerLoginLog> customerLoginLogLambdaQueryWrapper = new LambdaQueryWrapper<>();
        customerLoginLogLambdaQueryWrapper.eq(customerId != null && !"".equals(customerId), CustomerLoginLog::getCustomId, customerId);
        customerLoginLogLambdaQueryWrapper.between(startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime), CustomerLoginLog::getCreateTime, startTime, endTime);
        return customerLoginLogMapper.selectPage(page, customerLoginLogLambdaQueryWrapper);

    }
}




